# $Id$
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Troy C < rstrox -ta yahoo -tod com >

pkgbase=python-wrapt
pkgname=(python-wrapt python2-wrapt)
pkgver=1.10.11
pkgrel=1
pkgdesc="A Python module for decorators, wrappers and monkey patching"
arch=("i686" "x86_64")
url="https://pypi.python.org/pypi/wrapt"
license=("BSD")
makedepends=('python' 'python2')
checkdepends=('python-pytest' 'python2-pytest')
source=("$pkgname-$pkgver.tar.gz::https://github.com/GrahamDumpleton/wrapt/archive/$pkgver.tar.gz")
sha512sums=('cc051749341bcd6fc1a950607fad94f74334a00acf0366129470181a5af7a3af32a26e5c5deee9242ee12bcc7e4c47dacb958c514aba8a764be3bcc662845b98')

prepare() {
  cp -a wrapt-$pkgver{,-py2}
}

build() {
  cd "$srcdir"/wrapt-$pkgver
  python setup.py build

  cd "$srcdir"/wrapt-$pkgver-py2
  python2 setup.py build
}

check() {
  cd "$srcdir"/wrapt-$pkgver
  PYTHONPATH="$PWD/build/lib.linux-$CARCH-3.6:$PYTHONPATH" py.test

  cd "$srcdir"/wrapt-$pkgver-py2
  PYTHONPATH="$PWD/build/lib.linux-$CARCH-2.7:$PYTHONPATH" py.test2
}

package_python-wrapt() {
  depends=('python')

  cd wrapt-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

package_python2-wrapt() {
  depends=('python2')

  cd wrapt-$pkgver-py2
  python2 setup.py install --root="$pkgdir" --optimize=1
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
